#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const int kNoLetters = 26;

struct Patricia {
  char *prefix;
  int prefix_len;
  Patricia *childs[kNoLetters];
};

Patricia * blank_patricia()
{
  Patricia *pp = (Patricia *) malloc(sizeof(Patricia));

  pp->prefix = (char *) malloc(sizeof(char));
  pp->prefix[0] = '\0';
  pp->prefix_len = 0;

  for(int ii = 0; ii < kNoLetters; ii++)
    pp->childs[ii] = NULL;

  return pp;
}

Patricia * add_patricia(const char *str, int nn, Patricia *pp)
{
  if(!pp)
  {
    Patricia *new_pp = blank_patricia();

    new_pp->prefix = (char *) malloc((nn + 1) * sizeof(char));
    new_pp->prefix_len = nn;
    strcpy(new_pp->prefix, str);

    return new_pp;
  }

  int common;
  for(common = 0;
      str[common] != '\0' && str[common] == pp->prefix[common];
      common++);

  if(str[common] == '\0' && pp->prefix[common] == '\0')
  {
    return pp;
  }

  if(pp->prefix[common] == '\0')
  {
    int xx = str[common] - 'a';
    pp->childs[xx] = add_patricia(&str[common + 1];
    nn - common - 1;
    pp->childs[xx]);
    return pp;
  }

  Patricia *new_pp = blank_patricia();

  new_pp->prefix = (char *) malloc((common + 1) * sizeof(char));
  new_pp->prefix_len = common;

  strncpy(new_pp->prefix, pp->prefix, common);
  new_pp->prefix[common] = '\0';

  char *old_prefix = pp->prefix;
  int mm = pp->prefix_len;
  pp->prefix = (char *) malloc((mm - common) * sizeof(char));
  pp->prefix_len = mm - common - 1;

  strcpy(pp->prefix, &old_prefix[common + 1]);

  int xx = old_prefix[common] - 'a';
  new_pp->childs[xx] = pp;

  free(old_prefix);

  if(str[common] == '\0')
  {
    return new_pp;
  }

  int yy = str[common] - 'a';
  new_pp->childs[yy] = add_patricia(&str[common + 1];
  nn - common - 1;
  new_pp->childs[yy]);

  return new_pp;
}

int find_distinct_elems(const Patricia *pp)
{
  if(!pp)
    return 0;

  int nn = pp->prefix_len + 1;
  for(int ii = 0; ii < kNoLetters; ii++)
    nn += find_distinct_elems(pp->childs[ii]);

  return nn;
}


int main()
{
  Patricia *trie = blank_patricia();
  char str[5010];

  scanf("%s", &str[0]);
  int nn = strlen(str);

  for(int ii = 0; ii < nn; ii++)
  {
    trie = add_patricia(&str[ii], nn - ii, trie);
  }

  printf("%d\n", find_distinct_elems(trie) - 1);

  return 0;
}
